using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace GameLib
{
    public class LogManager
    {
        static int history = 30;
        static Queue<string> logmessages = new Queue<string>(history);

        public static void AddMessage() {
            AddMessage("\n");
        }
        public static void AddMessage(string text)
        {
            Console.WriteLine(text);
            logmessages.Enqueue(text);
        }

        public static void Update(GameTime gameTime)
        {
            if (logmessages.Count > history) {
                logmessages.Dequeue();
            }
        }

        public static void Draw(SpriteBatch batch)
        {
            SpriteFont font = Fonts.Pixel;
            Vector2 position = new Vector2(950, font.LineSpacing);

            batch.Begin();

            foreach (string item in logmessages)
            {
                string s = Fonts.BreakTextIntoLines(item, 50);
                batch.DrawString(font, s, position, Color.Yellow);
                position.Y += font.MeasureString(s).Y;
            }

            batch.End();
        }
    }
}
